<!--{template common/header_simple_start}-->
<link href="{MOD_PATH}/images/folder.css?{VERHASH}" rel="stylesheet" media="all">
<link href="static/dzzthumb/jquery.dzzthumb.css?{VERHASH}" rel="stylesheet" media="all">
<script type="text/javascript" src="static/dzzthumb/jquery.dzzthumb.js?{VERHASH}"></script>
<link rel="stylesheet" type="text/css" href="static/lyear/js/bootstrap-lyear-select/bootstrap-lyear-select.css">
<style type="text/css">
	.overflow-auto{
		max-height: 60px;
	}
	.lie{
		min-width: 120px
	}
</style>
<!--{template common/header_simple_end}-->
<!--{template common/commer_header}-->
<script type="text/javascript">
	var selorg={};
	selorg.add=function(ctrlid,vals){
		if(vals[0].orgid=='other') vals[0].path='{lang please_select_a_organization_or_department}';
		jQuery('#'+ctrlid+'_Menu').html(vals[0].path+' ');
		jQuery('#sel_'+ctrlid).val(vals[0].orgid);
		//jQuery('#orgid_{$org[orgid]}_Menu').dropdown('toggle');
	}
</script>
<div class="bs-container clearfix">
	<div class="bs-left-container  clearfix">
		<!--{template left}-->
	</div>
	<div class="left-drager">
    <div class="left-drager-op">
      <div class="left-drager-sub"></div>
    </div>
  </div>
  <div class="bs-main-container">
		<!--{if !$list}-->
		<p class="no-result-title text-center">暂无文件</p>
		<!--{else}-->
    <div class="clearfix">
      <ol class="breadcrumb">
        <li class="home" data-href="{MOD_URL}"><a href="{MOD_URL}" >{lang all_typename_attach}<span>></span></a></li>
        <!--{if !empty($foldername)}-->
        {eval $i=0;}
       {loop $foldername $v}
       {eval $i++;}
       <!--{if $i==count($foldername)}-->
       <li class="active"  data-fid="$v[fid]">$v[fname]<span></span></li>
       <!--{else}-->
        <li class=""  data-fid="$v[fid]"><a href="{MOD_URL}&pfid=$v[fid]">$v[fname]<span>></span></a></li>
        <!--{/if}-->
        {/loop} 
        <!--{/if}--> 
      </ol>
    </div>
    <div class="main-header clearfix">
      <form name="search" class="form-horizontal" action="{BASESCRIPT}" method="get">
        <input type="hidden" name="mod" value="filemanage" />
        <ul class="nav nav-pills">
          <li>
            <select class="form-select" name="pfid">
              <option value="" selected="selected">{lang file_position}</option>
              <option value="-1" &lt;!&ndash;{if $pfid==-1}&ndash;&gt;selected="selected"&lt;!&ndash;{/if}&ndash;&gt;>{lang in_recycle}
              </option>
            </select>
          </li>
					<!--{if $_G[adminid]==1}-->
          <!--{if !isset($pfid) || $pfid <= 0}-->
          <li class="dropdown org">
            <input id="sel_orgid_{$org[orgid]}" type="hidden" name="orgid"  value="$org[orgid]" onchange="selDepart(this)" />
            <button type="button" id="orgid_{$org[orgid]}_Menu" class="btn btn-primary dropdown-toggle" data-bs-toggle="dropdown"> $org[depart]  </button>
            <div id="orgid_$orgid_dropdown_menu" class="dropdown-menu org-sel-box" role="menu" aria-labelledby="orgid_{$org[orgid]}_Menu">
              <iframe name="orgid_{$org[orgid]}_iframe" class="org-sel-box-iframe" src="index.php?mod=system&op=orgtree&ctrlid=orgid_{$org[orgid]}&nouser=1&range=0&stype=1&moderator=1&zero={eval echo urlencode('{lang unselect_a_organization_or_department}');}" frameborder="0" marginheight="0" marginwidth="0" width="100%" height="100%" allowtransparency="true" ></iframe>
            </div>
          </li>
          <!--{/if}-->
					<!--{/if}-->
          <li class="pull-left">
            <input type="hidden" name="pfid" id="pfid" value="$pfid"/>
            <button  class="btn btn-primary " type="submit">{lang search}</button>
          </li>
          <li class="pull-left btn-secetlt" style="display: none;">
            <button  class="btn btn-danger " type="submit" value="{lang delete}" onclick="delete_file();">{lang delete}</button>
          </li>
					<li class="pull-left btn-secetlt" style="display: none;">
            <button  class="btn btn-primary col sharepame-selected" disabled>({lang checkednum})</button>
          </li>
        </ul>
      </form>
    </div>
    <form id="appform" name="appform" class="form-horizontal " action="{BASESCRIPT}?mod=filemanage" method="post" >
      <input type="hidden" name="delsubmit" value="true" />
      <input type="hidden" name="formhash" value="{FORMHASH}" />
			<input type="hidden" name="lpp" value="20">
      <input type="hidden" name="refer" value="$refer" />

      <table class="table table-hover">
        <thead node-type="title" class="title">
          <tr class="item clearfix">
            <th>
              <div class="col-sm-10">
                <div class="form-check">
                  <input class="form-check-input" name="del[]" type="checkbox" id="chkall"><label></label>
                </div>
              </div>
            </th>
            <th node-type="title-col" data-key="name" class="lie col">{lang filename}<span node-type="order-status" class="asc $_GET[name]" style="visibility: <!--{if $_GET[name]}-->visible<!--{else}-->hidden<!--{/if}-->;"></span></span></th>
            <th node-type="title-col" data-key="size" class="lie col">{lang file_size}<span node-type="order-status" class="asc $_GET[size]" style="visibility:<!--{if $_GET[size]}-->visible<!--{else}-->hidden<!--{/if}-->;"></span></th>
            <th node-type="title-col" data-key="ftype" class="lie col">{lang file_type}<span node-type="order-status" class="asc $_GET[ftype]" style="visibility: <!--{if $_GET[ftype]}-->visible<!--{else}-->hidden<!--{/if}-->;"></span></th>
            <th class="lie">{lang file_location}</th>
            <!--{if $_G[adminid]}-->
            <th node-type="title-col" data-key="username" class="lie col">{lang possessor}<span node-type="order-status" class="asc $_GET[username]" style="visibility: <!--{if $_GET[username]}-->visible<!--{else}-->hidden<!--{/if}-->;"></span></th>
            <!--{/if}-->
            <th node-type="title-col" data-key="dateline" class="lie col">{lang add_time} <span node-type="order-status" class="asc $_GET[dateline]" style="visibility: <!--{if $_GET[dateline]}-->visible<!--{else}-->hidden<!--{/if}-->;"></span></th>
            <th class="lie">操作</th>
          </tr>
        </thead>
        <tbody node-type="list" class="list list-share">
          <!--{loop $list $key $value}-->
          <tr node-type="item" data-dpath="$value[dpath]" data-rid="$value[rid]" <!--{if $value[type] == 'folder' && $value[oid]}--> data-containpath="$value[oid]"<!--{/if}--> data-type="$value[type]" class="item shareblock clearfix">
            <td data-name="$value[name]" class="col">
              <div class="col-sm-10">
                <div class="form-check">
                  <input type="checkbox" class="form-check-input"  name="del[]" value="$value[rid]" data-rid="$value[rid]">
                </div>
              </div>
            </td>
            <td node-type="name" class="name" title="$value[name]" data-size="$value[name]"><div class="overflow-auto"> 
              <!--{if $value[img]}--><img class="icon" title="$value[name]" src="$value[img]" <!--{if $value[type]=='image' }--> data-original="$value[url]" data-dpath="$value[dpath]" 
              <!--{/if}-->/> 
              <!--{/if}--> 
              <span node-type="name-text" data-href="$value[shareurl]" class="name-text enabled">$value[name]</span></div>
            </td>
            <td><!--{if $value[type]=='folder'}--><!--{else}--><div class="overflow-auto">$value[fsize]</div><!--{/if}--></td>
            <td><div class="overflow-auto">$value[ftype]</div></td>
            <td><div class="overflow-auto">$value[relpath]</div></td>
            <!--{if $_G[adminid]}-->
            <td><div class="overflow-auto">$value[username]</div></td>
            <!--{/if}-->
            <td><div class="overflow-auto">$value[fdateline]</div></td>
            <td>
              <div>
                <a node-type="btn-item" data-key="download" class="btn btn-outline-info" title="下载" href="javascript:void(0);"><i class="dzz dzz-download"></i></a>
                <a class="btn btn-outline-info" href="{BASESCRIPT}?mod=filemanage&do=delete&icoid=$value[rid]&refer={eval echo urlencode($refer);}" data-bs-toggle="tooltip" title="{lang delete}" onclick="if(confirm('{lang filemanage_del_file}')){return true}else{return false}"><i class="dzz dzz-delete"></i></a>
                <!--{if $value[type]=='folder'}--><!--{else}-->
                <a class="btn btn-outline-info" href="javascript:;" onclick="togglecplog('{$key}')" data-bs-toggle="tooltip" title="更多信息"><i class="dzz dzz-description"></i></a>
                <!--{/if}-->
              </div>
            </td>
          <!--{if $value[type]=='folder'}--><!--{else}-->
          <tr id="cplog_{$key}" style="display:none">
            <td colspan="8">
              <!--{if $_G[adminid]}-->
            <!--{if $value[type]=='folder'}--><!--{else}-->
                文件位置：<!--{eval echo IO::getStream($value[path])}-->
              <br/>
                直链地址：<a href="<!--{eval echo IO::getFileUri($value[path])}-->"><!--{eval echo IO::getFileUri($value[path])}--></a>
              <br/>
                引用：$value[copys]
            <!--{/if}-->
            <!--{/if}--></td>
          </tr>
          <!--{/if}-->
          </tr>
          <!--{/loop}--> 
        </tbody>
      </table>
      <div class="pull-left">
        <div class="input-group mb-3">
          <span class="input-group-text">每页显示</span>
          <select class="form-select" onchange="if(this.options[this.selectedIndex].value != '') {this.form.lpp.value = this.options[this.selectedIndex].value;this.form.submit(); }">
            <option value="10" $checklpp[10]> 10 </option>
            <option value="20" $checklpp[20]> 20 </option>
            <option value="40" $checklpp[40]> 40 </option>
            <option value="100" $checklpp[100]> 100 </option>
						<option value="200" $checklpp[200]> 200 </option>
          </select>
          <span class="input-group-text">条记录</span>
        </div>
      </div>
      $multi
    </form>
  </div>
	<!--{/if}-->
  </div>
</div>

<iframe id="hideframe" name="hideframe" src="about:blank" frameBorder="0" marginHeight="0" marginWidth="0" width="0" height="0" allowtransparency="true" style="display:none;z-index:-99999"></iframe>
<script type="text/javascript">
var theurl='$theurl';
	jQuery(document).ready(function(e) {
    jQuery('select').lyearSelect({
      width:70,
    });
		jQuery('.title .item .col[node-type=title-col][data-key=dateline],.title .item .col[node-type=title-col][data-key=name],.title .item .col[node-type=title-col][data-key=size],.title .item .col[node-type=title-col][data-key=username],.title .item .col[node-type=title-col][data-key=ftype],.title .item .col[node-type=title-col][data-key=ftype]').on('click', function() {
			var el = jQuery(this);
			el.find('.asc').css('visibility', 'visible').toggleClass('desc');
			el.siblings().find('.asc').css('visibility', 'hidden');
			
			var param=el.data('key')+'='+ (el.find('.asc').hasClass('desc') ? 'desc' : 'asc');
			var regx=new RegExp('&(dateline|size|name|username|ftype)=(asc|desc)','i');
			var url=theurl.replace(regx,'')+'&'+param;
			location.href=correcturl(url);
		});
		jQuery(document).on('click', 'a[data-key=download]', function() {
			download(this);
			return false;
		});
		jQuery('img[data-original]').dzzthumb();
		jQuery(document).on('click', 'span[node-type=name-text],.module-grid-view .item', function() {
			var item = jQuery(this).closest('.item');
			var type = item.data('type');
			if(item.closest('.module-grid-view').length) {
				var rander = 'grid';
			} else {
				var rander = 'list';
			}
			if(type == 'folder') {
				jQuery('#pfid').val(item.data('containpath'));
				location.href='{MOD_URL}&pfid=' + item.data('containpath');
				return false;
			} else {
				if(type == 'image' && item.find('img[data-original]').trigger('click.dzzthumb')) {} else {
					var preurl = 'share.php?a=view&s=' + item.data('dpath');
					if(top._config) {
						top.OpenWindow('url', preurl, item.find('img').attr('title'), null, { img: item.find('img').attr('src'), name: item.find('img').attr('title') });
					} else {
						window.open(preurl, jQuery(this).html());
					}
				}
			}
			return false;
		});
	});
   function download(obj) {
		var li = jQuery(obj).closest('.item');
	
		var url = DZZSCRIPT + '?mod=io&op=download&path=' + li.data('dpath');
		if(BROWSER.ie) {
			window.open(correcturl(url));
		} else {
			window.frames['hideframe'].location = correcturl(url);
		}
	}
	
var rids=[];
//复选框选中问题
jQuery(document).off('click.shareclick').on('click.shareclick',".shareblock",function(){
	var checkinput = jQuery(this).find("input[name='del[]']");
	if(checkinput.prop('checked')){
		checkinput.prop('checked',false);
		jQuery(this).removeClass('item-block');
		var rid=jQuery(this).find('input[name="del[]"]').data('rid');
		var index = jQuery.inArray(rid,rids);
		if(index != -1){
			rids.splice(index,1);
		}

	}else{
		checkinput.prop('checked',true);
		jQuery(this).addClass('item-block');
		var rid=jQuery(this).data('rid');
			if(jQuery.inArray(rid,rids) == -1){
				rids.push(rid);
			}

	}
	sharelength();
});
jQuery(document).off('click.inputclick').on('click.inputclick',".shareblock input[name='del[]']",function(){
	if($(this).prop('checked')){
		jQuery(this).prop('checked',false);
		jQuery(this).removeClass('item-block');
		
	}else{
		jQuery(this).prop('checked',true);
		jQuery(this).addClass('item-block');
	}
});
//复选框全选
jQuery(document).off('click.allclick').on('click.allclick','#chkall',function(){
	var allchecked=jQuery(this).prop('checked');
	jQuery(this).closest('.title').next('.list-share').find('input[name="del[]"]').each(function(){
		if(allchecked){
			jQuery(this).prop('checked',true);
			jQuery(this).closest('.item').addClass('item-block');
			var rid=jQuery(this).data('rid');
			if(jQuery.inArray(rid,rids) == -1){
				rids.push(rid);
			}
		}else{
			jQuery(this).prop('checked',false);
			jQuery(this).closest('.item').removeClass('item-block');
			var rid=jQuery(this).data('rid');
			var index = jQuery.inArray(rid,rids);
			if(index != -1){
				rids.splice(index,1);
			}

		}
	});
	sharelength();
})

function sharelength(){
	if(rids.length>0){
		jQuery('.sharepame-selected').show().next('.show_first').hide();
		jQuery('#chkall').prop('checked',true);
		jQuery('.btn-secetlt').show();
	}else{
		jQuery('.sharepame-selected').hide().next('.show_first').show();
		jQuery('#chkall').prop('checked',false);
		jQuery('.btn-secetlt').hide();
	}
	jQuery('.ex-number').html(rids.length);
}
function delete_file(){
	var delnums = rids.length;
	var icoids = rids.join(',');
	if(confirm('{lang Are you sure you want to delete this}'+delnums+'{lang file (if it is a folder, all the sub files under it will be deleted)? Cannot recover after deletion}')){
		jQuery.post('{MOD_URL}&do=delete',{'icoid':icoids},function(data){
			if(data['success']){
				window.location.reload();
			}else{

			}
		})
	}
}
function togglecplog(k) {
  var cplogobj = document.getElementById('cplog_' + k);
  if(cplogobj.style.display == 'none') {
    cplogobj.style.display = '';
  } else {
    cplogobj.style.display = 'none';
  }
}
</script>
<script type="text/javascript" src="static/lyear/js/bootstrap-lyear-select/bootstrap-lyear-select.js"></script>
<!--{template common/footer_simple}-->